﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace quanlynhasach
{
    public partial class frmMain : Form
    {
        public static string user;
        public static bool quyen;
        public frmMain()
        {
            InitializeComponent();
        }
        private void exit(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void mLogout_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn muốn đăng xuất không ?", "Đăng xuất", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                this.Hide();
                frmLogin n = new frmLogin();
                n.Show();
            }
        }

        private void mChangepass_Click(object sender, EventArgs e)
        {
            frmChangepass c = new frmChangepass();
            c.ShowDialog();
        }

        private void mExit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn muốn thoát không ?", "Thoát", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            label1.Text = "      ...Nhà sách UIT...                                 Người đăng nhập: " + user.ToUpper();
            if (!quyen)
                mQuanlynv.Enabled = false;
        }

        private void btnBanHang_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmBanhang banhang = new frmBanhang();
            banhang.MdiParent = this;
            banhang.Show();
        }

        private void btnNhapHang_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmNhapHang nhaphang = new frmNhapHang();
            nhaphang.MdiParent = this;
            nhaphang.Show();
        }

        private void mTheLoai_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmTheloai theloai = new frmTheloai();
            theloai.MdiParent = this;
            theloai.Show();
        }

        private void NhaCungCap_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmNhacungcap nhacungcap = new frmNhacungcap();
            nhacungcap.MdiParent = this;
            nhacungcap.Show();
        }

        private void HangHoa_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmHanghoa hanghoa = new frmHanghoa();
            hanghoa.MdiParent = this;
            hanghoa.Show();
        }

        private void About_Click(object sender, EventArgs e)
        {
            frmAbout about = new frmAbout();
            about.ShowDialog();
        }

        private void InfoNhanVien_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmInfoNV infonv = new frmInfoNV();
            infonv.MdiParent = this;
            infonv.Show();
        }

        private void NhanVien_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmNhanvien nhanvien = new frmNhanvien();
            nhanvien.MdiParent = this;
            nhanvien.Show();
        }

        private void TimNhanVien_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmTimNV timnv = new frmTimNV();
            timnv.MdiParent = this;
            timnv.Show();
        }

        private void mTimhanghoa_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmTimhanghoa timhanghoa = new frmTimhanghoa();
            timhanghoa.MdiParent = this;
            timhanghoa.Show();
        }

        private void DoanhThu_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmReport report = new frmReport();
            report.MdiParent = this;
            report.Show();
        }

        private void TimNhaCungCap_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmTimNCC timncc = new frmTimNCC();
            timncc.MdiParent = this;
            timncc.Show();
        }

        private void KhachHang_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmKhachHang frmkhachhang = new frmKhachHang();
            frmkhachhang.MdiParent = this;
            frmkhachhang.Show();
        }

        private void nhậpHàngToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
            frmReportNhap report = new frmReportNhap();
            report.MdiParent = this;
            report.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label2.Text = System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
        }

        private void help_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.EnableRaisingEvents = false;
            proc.StartInfo.FileName = "help.pdf";
            proc.Start();
        }
    }
}
